package com.zyh.thread;

/**
 * @Author zyh
 * @Date 2024/8/7 16:38
 * @Description 守护线程
 */

public class ThreadDemo8 {
     public static void main(String[] args) {
          MyThread04 t1 = new MyThread04("线程A");
          t1.setDaemon(true);
          t1.start();
          MyTask05 myTask05 = new MyTask05();
          Thread t2 = new Thread(myTask05,"线程B");
          t2.start();
     }
}

class MyThread04 extends Thread{
     public MyThread04() {
     }

     public MyThread04(String name) {
          super(name);
     }

     @Override
     public void run() {
          for (int i = 0; i < 100000; i++) {
               System.out.println(Thread.currentThread().getName()+"正在播放背景音乐"+i);
          }
     }
}



class MyTask05 implements Runnable {
     @Override
     public void run() {
          for (int i = 0; i < 10; i++) {
               System.out.println(Thread.currentThread().getName()+"正在打游戏"+i);
          }
     }
}
